package com.darksider.darkotlin.net.module

import dagger.Module
import dagger.Provides
import okhttp3.OkHttpClient
import retrofit2.CallAdapter
import retrofit2.Converter
import retrofit2.Retrofit
import javax.inject.Singleton

/**
 * User: yaodong(1126220529@qq.com)
 * Date: 2017-05-26
 * Time: 12:41
 * Description: retrofit依赖模块 依赖BaseUrlModule Rx2AdapterModule
 * OkHttpClientModule GsonConverterModule 等模块
 * Update:
 */
@Module(includes = arrayOf(BaseUrlModule::class, Rx2AdapterModule::class, OkHttpClientModule::class, GsonConverterModule::class))
class RetrofitModule {
    @Singleton @Provides fun retrofit(baseUrl: String,
                                      okHttpClient: OkHttpClient,
                                      adapterFactory: CallAdapter.Factory,
                                      converterFactory: Converter.Factory): Retrofit = Retrofit
            .Builder()
            .baseUrl(baseUrl)
            .addCallAdapterFactory(adapterFactory)
            .addConverterFactory(converterFactory)
            .client(okHttpClient).build()
}